import React, {useState} from 'react';

import HRForm from '../index';
import {initState} from 'common/functions/factory';

export default () => {

    const state = initState({
        formData: {
            name: '新增岗位',
            code: '11111',
            superPost: '22222',
            count: 111,
            postTag: ['厉害', '新人', '高手'],
            postAbility: 'sadfasdfasdf',
            summary: 'asdfasdfasdfas'
        }
    });

    const changeForm = (formData) => {
        state.setFormData(formData);
    }

    return (
        <div
            style={{
                width: 800,
                margin: '0 auto',
                border: '1px solid #999',
                padding: '10px'
            }}
        >
            <HRForm
                formData={state.formData}
                onChange={changeForm}
                config={[{
                    label: '岗位名称',
                    type: 'input',
                    key: 'name',
                    rules: [{
                        required: true,
                        message: ''
                    }]
                }, {
                    label: '岗位编码',
                    type: 'input',
                    key: 'code',
                    rules: [{
                        required: true,
                        message: ''
                    }]
                }, {
                    label: '上级岗位',
                    type: 'input',
                    key: 'superPost',
                    rules: [{
                        required: true,
                        message: ''
                    }]
                }, {
                    label: '编制人数',
                    type: 'input',
                    key: 'count',
                    rules: [{
                        required: true,
                        message: ''
                    }]
                }, {
                    label: '岗位标签',
                    type: 'tag',
                    key: 'postTag',
                    singleLine: true
                }, {
                    label: '工作职责',
                    type: 'textarea',
                    key: 'postAbility',
                    singleLine: true,
                    options: {
                        max: 200
                    }
                }, {
                    label: '概述',
                    type: 'textarea',
                    singleLine: true,
                    key: 'summary'
                }]}
                cols={2}
            />
        </div>
    );
}